package observerexample.dataobj;


import java.util.Observable;


/**
 * @author yaojianfeng
 */
public class NewWeatherData extends Observable {

    private float temp;
    private float humidity;
    private float pressure;

    /**
     * 状态改变 通知观察者
     */
    public void measurementsChanged() {
        //调用notifyObserver方法之前调用此方法 代表状态已经改变
        setChanged();
        //调用此方法 可更新布告板显示内容
        notifyObservers();
    }

    public NewWeatherData() {
    }

    public void setTemp(float temp) {
        this.temp = temp;
    }

    public void setHumidity(float humidity) {
        this.humidity = humidity;
    }

    public void setPressure(float pressure) {
        this.pressure = pressure;
    }

    public float getTemp() {
        return temp;
    }

    public float getHumidity() {
        return humidity;
    }

    public float getPressure() {
        return pressure;
    }

    public void setMeasurements(float temp, float humidity, float pressure) {
        this.temp = temp;
        this.humidity = humidity;
        this.pressure = pressure;
        measurementsChanged();
    }
}
